package ar.edu.caece.compiler.grammar.factories;

import ar.edu.caece.compiler.grammar.AbstractTokenVisitorFactory;
import ar.edu.caece.compiler.grammar.TokenVisitor;

public class OTROSAFactory extends AbstractTokenVisitorFactory {

	private static OTROSAFactory INSTANCE;
	
	private OTROSA1Factory otrosa1Factory;
	private OTROSA2Factory otrosa2Factory;

	
	public static OTROSAFactory getInstance() throws Exception {
		if(INSTANCE==null) INSTANCE = new OTROSAFactory();
		return INSTANCE;
	}
	
	private Initializer initializer = new Initializer() {
		
		@Override
		public void init() throws Exception {
			initializer = NoOperationInitializer.getInstance();
			otrosa1Factory = OTROSA1Factory.getInstance();
			otrosa2Factory = OTROSA2Factory.getInstance();
		}
	};
	
	private OTROSAFactory() throws Exception {

	}
	
	@Override
	public TokenVisitor makeChainedVisitor(
			final TokenVisitor siguiente) throws Exception {
		initializer.init();

		return otrosa1Factory.makeChainedVisitor(otrosa2Factory.makeChainedVisitor(siguiente));
	
	}
	@Override
	public TokenVisitor makeVisitor() throws Exception {
		initializer.init();

		return otrosa1Factory.makeChainedVisitor(otrosa2Factory.makeVisitor());
	}
	
	
}
